package org.zxp.designpattern.singleton;

/**
 * @program: effectiveJava
 * @description: 饿汉 枚举 特点：可以防止序列化 反序列化后得到的对象不是同一个对象 还可以避免反射攻击
 * @author: X-Pacific zhang
 * @create: 2019-08-21 21:38
 **/
public enum Singleton6 {
    INSTANCE;

    private final Object o1;

    Singleton6(){
        o1 = new Object();
    }

    public static Singleton6 getInstance(){
        return INSTANCE;
    }

    public void print(){
        System.out.println(o1.hashCode());
    }
}
